package logic

import (
	"context"
	"fmt"
	"mall/mallrpc/internal/svc"
	"mall/mallrpc/mallrpc"
	"mall/model/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShLogic {
	return &ShLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品审核
func (l *ShLogic) Sh(in *mallrpc.ShRequest) (*mallrpc.ShResponse, error) {
	// todo: add your logic here and delete this line
	state := mysql.State{
		Liss: in.Liss,
		Down: in.Down,
	}
	mysql.DB.Debug().Where("userid=?", in.Userid).Find(&state)
	if state.ID == 0 {
		return nil, fmt.Errorf("数据不存在,无法")
	}
	return &mallrpc.ShResponse{
		Id: int64(state.ID),
	}, nil
}
